//
//  NoStarTableViewCell.m
//  TingliFeng
//
//  Created by xinxuan on 16/1/8.
//  Copyright © 2016年 Bullgo. All rights reserved.
//

#import "NoStarTableViewCell.h"

#import "UIView+SDAutoLayout.h"
#import "UITableView+SDAutoTableViewCellHeight.h"


@implementation NoStarTableViewCell

{
    UIImageView * _picView;
    UILabel * _nameLabel;
    UILabel * _detailLabel;
    UILabel * _periodLabel;
    UILabel * _personNumberLabel;
    UILabel * _timeLabel;
    UILabel * _levelLabel;
    

    
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        UIImageView * backgroundImageView = [[UIImageView alloc]init];
        _picView = backgroundImageView;
        
        UILabel * nameLabel = [[UILabel alloc]init];
        nameLabel.textColor = [UIColor whiteColor];
        nameLabel.font = [UIFont boldSystemFontOfSize:20];
        _nameLabel = nameLabel;
        
        UILabel * detailLabel = [[UILabel alloc]init];
        detailLabel.textColor = [UIColor whiteColor];
        detailLabel.font = [UIFont systemFontOfSize:12];
        _detailLabel = detailLabel;
        
        UILabel * periodLabel = [[UILabel alloc]init];
        periodLabel.textColor = [UIColor whiteColor];
        periodLabel.font = [UIFont systemFontOfSize:12];
        _periodLabel = periodLabel;
        
        UILabel * personNumberLabel = [[UILabel alloc]init];
        personNumberLabel.textColor = [UIColor whiteColor];
        personNumberLabel.font = [UIFont systemFontOfSize:12];
        _personNumberLabel = personNumberLabel;
        
        UILabel * timeLabel = [[UILabel alloc]init];
        timeLabel.textColor = [UIColor whiteColor];
        timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel = timeLabel;
        
        UILabel * levelLabel = [[UILabel alloc]init];
        levelLabel.textColor = [UIColor whiteColor];
        levelLabel.font = [UIFont systemFontOfSize:15];
        levelLabel.backgroundColor = [UIColor colorFromHexString:@"#82bc10"];
        levelLabel.textAlignment = NSTextAlignmentCenter;
        levelLabel.layer.masksToBounds = YES;
        levelLabel.layer.cornerRadius = 6;
        _levelLabel = levelLabel;
        
        _picView.sd_layout
        .topSpaceToView(self.contentView,0)
        .bottomSpaceToView(self.contentView ,5)
        .leftSpaceToView(self.contentView ,0)
        .rightSpaceToView(self.contentView ,0);
        
        _nameLabel.sd_layout
        .widthIs(100)
        .heightIs(18)
        .topSpaceToView(self.contentView, 14)
        .leftSpaceToView(self.contentView, 11);
        
        _detailLabel.sd_layout
        .leftSpaceToView(self.contentView,10)
        .topSpaceToView(self.contentView,40)
        .widthIs(300)
        .heightIs(20);
        
        _periodLabel.sd_layout
        .widthRatioToView(self.contentView, 0.15)
        .heightIs(20)
        .bottomSpaceToView(self.contentView, 10)
        .leftSpaceToView(self.contentView, 10);
        
        _personNumberLabel.sd_layout
        .bottomSpaceToView(self.contentView, 10)
        .leftSpaceToView(self.contentView ,120)
        .widthRatioToView(self.contentView, 0.3)
        .heightIs(20);
        
        _timeLabel.sd_layout
        .widthRatioToView(self.contentView, 0.25)
        .heightIs(20)
        .rightSpaceToView(self.contentView,10)
        .bottomSpaceToView(self.contentView, 10);
        
        _levelLabel.sd_layout
        .topSpaceToView(self.contentView, 10)
        .rightSpaceToView(self.contentView,9)
        .widthIs(41)
        .heightIs(21);
        
        
        
        UIImageView *view0 = [UIImageView new];
        view0.backgroundColor = [UIColor redColor];
        _view0 = view0;
        
        UIView *view1 = [UIView new];
        view1.backgroundColor = [UIColor grayColor];
        _view1 = view1;
        
        UILabel *view2 = [UILabel new];
        view2.backgroundColor = [UIColor brownColor];
        _view2 = view2;
        
        UILabel *view3 = [UILabel new];
        view3.backgroundColor = [UIColor orangeColor];
        _view3 = view3;
        
        UIView *view4 = [UIView new];
        view4.backgroundColor = [UIColor purpleColor];
        _view4 = view4;
        
        [self.contentView addSubview:backgroundImageView];
        [self.contentView addSubview:nameLabel];
        [self.contentView addSubview:detailLabel];
        [self.contentView addSubview:periodLabel];
        [self.contentView addSubview:personNumberLabel];
        [self.contentView addSubview:timeLabel];
        [self.contentView addSubview:levelLabel];
        
        [self.contentView addSubview:view0];
        [self.contentView addSubview:view1];
        [self.contentView addSubview:view2];
        [self.contentView addSubview:view3];
        [self.contentView addSubview:view4];
        
    }
    return self;
}




- (void)setModel:(CommenModel *)model
{
    _model = model;
    
    _picView.image = [UIImage imageNamed:model.pic];
    _nameLabel.text = model.name;
    _detailLabel.text = model.centent;
    _periodLabel.text = model.period;
    _personNumberLabel.text = model.personNumber;
    _timeLabel.text = model.time;
    _levelLabel.text = model.level;
    
}


@end
